package indi.lddsdu.index;

import org.junit.Test;

import java.io.File;
import java.io.IOException;

/**
 * Created by jack on 18/6/18.
 */
public class FileFormatterTest {
    @Test
    public void deleteSpaceTest() throws IOException {
        File source = new File("/Users/jack/Desktop/0f5a3955-bfd7-4b13-b158-1883b5ccc8f3.txt");
        File target = new File("/Users/jack/Desktop/1.txt");
        FileFormatter.deleteSpace(source, target);
    }

    /**
     * 删除文件中的多余空格
     */
    @Test
    public void deleteSpaceTest2() throws IOException {
        File file = new File(FileFormatter.SOURCE_FOLDER);
        File[] files = file.listFiles();
        for( File source : files){
            String fileName = source.getName();
            if (!fileName.endsWith(".txt")){
                continue;
            }
            String targetName = FileFormatter.TARGET_FOLDER+"/"+fileName;
            File target = new File(targetName);
            FileFormatter.deleteSpace(source, target);
        }
    }
}
